package com.closer.service.biz.chatHistory.validator;

import cn.hutool.core.util.StrUtil;
import com.closer.service.biz.user.dto.vo.LoginUserVO;
import com.closer.service.support.exception.ErrorCode;
import com.closer.service.support.exception.ThrowUtils;
import org.springframework.stereotype.Component;

@Component
public class HistoryValidator {


    public void addValidate(Long appId, String message, String messageType, Long userId) {
        ThrowUtils.throwIf(appId==null || appId <= 0, ErrorCode.PARAMS_ERROR, "应用ID不能为空");
        ThrowUtils.throwIf(StrUtil.isBlank(message), ErrorCode.PARAMS_ERROR, "消息内容不能为空");
        ThrowUtils.throwIf(StrUtil.isBlank(messageType), ErrorCode.PARAMS_ERROR, "消息类型不能为空");
        ThrowUtils.throwIf(userId==null || userId <= 0, ErrorCode.PARAMS_ERROR, "用户ID不能为空");
    }

    public void pageValidator(Long appId, int pageSize, LoginUserVO loginUser) {
        ThrowUtils.throwIf(appId==null || appId <= 0, ErrorCode.PARAMS_ERROR, "应用ID不能为空");
        ThrowUtils.throwIf(pageSize<=0 || pageSize > 50, ErrorCode.PARAMS_ERROR, "页码大小必须在1-50之间");
        ThrowUtils.throwIf(loginUser==null , ErrorCode.NOT_LOGIN_ERROR, "用户未登陆");
    }
}
